<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      let pageNo
      let pageSize = 2
      let recordCount
      let pageCount = 0

      function Pagination() {}

      function Pagination(pageNo, recordCount) {
        this(pageNo, 2, recordCount)
      }

      function Pagination(pageNo, pageSize, recordCount) {
        this.pageNo = pageNo
        this.pageSize = pageSize
        this.recordCount = recordCount
        init()
      }

      function init() {
        this.pageCount = Math.ceil((recordCount * 1.0) / pageSize)
      }

      function getFirst() {
        return 1
      }

      function getLast() {
        return this.pageCount
      }

      function getPrev() {
        return Math.max(1, this.pageNo - 1)
      }

      function getNext() {
        return Math.min(this.pageCount, this.pageNo + 1)
      }
    </script>
  </body>
</html>
